package com.wyz.saas.app.mvvm.main

import android.view.View
import androidx.lifecycle.viewModelScope
import com.atom.module.mvvm.adapter.ClickEvent
import com.atom.module.mvvm.base.AbstractBaseViewModel
import com.atom.module.mvvm.base.EmptyModel
import com.wyz.saas.app.mvvm.list.ListActivity
import com.wyz.saas.common.base.AbstractApiViewModel
import com.wyz.saas.common.impl.EmptyApiModel
import com.wyz.saas.common.utils.JacksonUtils
import com.wyz.saas.common.utils.Logs
import com.wyz.saas.module.chat.ChatModuleApplication
import com.wyz.saas.module.patrol.PatrolModuleApplication
import kotlinx.coroutines.launch
import timber.log.Timber

class TestViewModel : AbstractApiViewModel<EmptyApiModel> {

    constructor(id: Int, model: EmptyApiModel) : super(id, model)

    val test_textView = object : ClickEvent<Unit>() {
        override fun invoke(t: View) {
            Logs.e("asdasdasdasdasd")
            apiContext().execute {
                val alphabetizedWords =
                    ChatModuleApplication.INSTANCE.database.userDao().getAlphabetizedWords()
                Timber.e("%s", JacksonUtils.objectMapper().writeValueAsString(alphabetizedWords))
                val patrol =
                    PatrolModuleApplication.INSTANCE.database.patrolCheckpointDao()
                        .getAlphabetizedWords()
                Timber.e("%s", JacksonUtils.objectMapper().writeValueAsString(patrol))
            }
        }
    }
    val test_list = object : ClickEvent<Unit>() {
        override fun invoke(t: View) {
            startActivity(ListActivity::class.java)
        }
    }
    val test_login = object : ClickEvent<Unit>() {
        override fun invoke(t: View) {
            viewModelScope.launch {

            }
        }
    }
}